package com.lanou3g.ptp.api.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lanou3g.ptp.entity.School;
import com.lanou3g.ptp.organize.service.SchoolService;
import com.lanou3g.utils.PtpResult;
import com.lanou3g.utils.PtpResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "学校接口")
@RestController
public class SchoolController {
    @Reference
    private SchoolService schoolService;

    @ApiOperation("通过id获取学校")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "学校id")
    })

    @GetMapping("/school/{id}")
    public PtpResult findById(@PathVariable Long id) {
        School school = schoolService.findById(id);
        return PtpResultUtils.ok(school);
    }

    @ApiOperation("通过id修改学校")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "学校id")
    })
    @PutMapping("/school")
    public PtpResult updateById(@Param("id") Long id, @Param("school") School school){
        schoolService.updateById(id,school);
        return PtpResultUtils.ok(2333);
    }
}
